/**
 * Node-oracledb supports Promises with all asynchronous methods.
 */

import oracle = require("oracledb");
import dbConfig = require("../config/dbConfig");

let config = dbConfig.config;

let connectionPromise = oracle.getConnection(config);
    
connectionPromise.then(function(connection){
    let executePromise = connection.execute(
        "select * from TNMS.T_USER t "
        +"where t.id = :id",
        ["huyl"]
    );

    executePromise.then(function(result){
        console.log(result);
        return connection.close();
    }).catch(function(err){
        console.error(err.message);
        return connection.close();
    });
}).catch(function(err){
    console.error(err.message);
});